Bokeh has a few examples up in the bokeh gallery, but there's a rich, and somewhat hidden, resource - the bokeh examples directory.

Here we'll look at how to run and play with the bokeh examples.

Getting the correct examples

The most important thing is to make sure you're running the examples that match the version of bokeh you're running. Find your bokeh version as follows


In [9]:
from bokeh import __version__
__version__


Out[9]:
'0.11.1'

There are a few of options for getting the examples. In increasing order of difficulty:

  • download a zip that I made
  • find the examples installed when you conda installed bokeh
  • run from your local build of bokeh

Download a pre-made zip

I have made zip files of the examples for recent releases of bokeh:

I will keep adding new ones on the examples page

Find in your conda installation

From the command line you can find where bokeh is running from, and from this we can find our examples. First find bokeh with which bokeh:

(bokeh)➜  pages git:(master) ✗ which bokeh
/Users/birdsarah/miniconda3/envs/bokeh/bin/bokeh

Next go to the directory one above bin. In my case that's:

$ cd /Users/birdsarah/miniconda3/envs/bokeh

In that directory you should find a directory called Examples. This is where all the bokeh examples live.

Running with locally installed bokeh (advanced)

If you're hacking on bokeh bokeh you may want to run the examples against your local version of bokeh.

Background on bokeh "Resources"

Bokeh has a default setting which is helpful for regular bokeh users but can confuse new Bokeh developers. Bokeh has two parts to it the python part (from bokeh import ...) and the javascript part (aka bokehjs). By default bokeh uses a pre-built version of bokehjs that lives on our cdn. This is super useful for users because it means that the html they produce isn't full of the bokehjs library. However, the pre-built version of bokehjs will be the latest release version and is almost certainly not compatible with bokeh master which we're downloading an running locally.

Which version of bokehjs we're using is managed through bokeh.resources and you can read more here: http://bokeh.pydata.org/en/dev/docs/reference/resources.html

Using environment variables

We have a set of environment variables that we can set so that bokeh just does the right thing when we're developing. You can see a complete list here: http://bokeh.pydata.org/en/dev/docs/dev_guide/env_vars.html

I often use BOKEH_DEV=true but that can have the side effect of running